package light.head.framework.base;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import light.head.constant.Parm;
import light.head.dao.sys.RoleHandleDAO;

import org.springframework.beans.factory.annotation.Autowired;

public class SupporterController extends BaseController {
	
//	protected Boolean cu_isManager = null;
//	protected Integer cu_organTypeCode = null;
//	protected String cu_pageStyle = null;

	private RoleHandleDAO rhDAO;
	
	/**
	 * 获取当前用户的handleMap
	 */
	protected Map<String, Boolean> getCurrentUserHandleMap(HttpServletRequest request) {
		return rhDAO.getHandleMapByRoleCode(cu_roleCode(request));
	}
	
	/**
	 * 根据参数名称获取查询条件Map
	 */
	protected Map<String, String> createQueryMapByParmName(HttpServletRequest request, final String...names) {
		if (null == names || 0 == names.length)
			return null;
		
		Map<String, String> map = new HashMap<String, String>();
		for (String name : names) {
			map.put(name, request.getParameter(name));
		}
		
		Integer cu_organCode = cu_organCode(request);
		map.put(Parm.ORGAN_CODE, null != cu_organCode ? cu_organCode.toString() : null);
		return map;
	}
	
	public Boolean cu_isManager(HttpServletRequest request) {
		Boolean cu_isManager = (Boolean)request.getSession().getAttribute(Parm.CU_IS_MANAGER);
		return cu_isManager;
	}
	
	public Integer cu_organTypeCode(HttpServletRequest request) {
		Integer cu_organTypeCode = (Integer)request.getSession().getAttribute(Parm.CU_ORGAN_TYPE_CODE);
		return cu_organTypeCode;
	}

//	public void setCu_isManager(Boolean cuIsManager) {
//		this.cu_isManager = cuIsManager;
//	}
//	public void setCu_organTypeCode(Integer cuOrganTypeCode) {
//		this.cu_organTypeCode = cuOrganTypeCode;
//	}
//	public void setCu_pageStyle(String cuPageStyle) {
//		this.cu_pageStyle = cuPageStyle;
//	}
	
	
	@Autowired
	public void setRhDAO(RoleHandleDAO rhDAO) {
		this.rhDAO = rhDAO;
	}
}
